home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dskut / aspisrc.zip / RMT.H < prev    next >
C/C++ Source or Header  |  1992-01-26  |  3KB  |  95 lines

  1. /* Remote tape drive defines for tar.
  2.    Copyright (C) 1988 Free Software Foundation
  3.  
  4. This file is part of GNU Tar.
  5.  
  6. GNU Tar is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 1, or (at your option)
  9. any later version.
  10.  
  11. GNU Tar is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU Tar; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #ifdef NO_REMOTE
  21.  
  22. #ifdef ASPI
  23. extern int aspiopen(char *, int, int);
  24. extern int aspiread(int, char *, int);
  25. extern int aspiwrite(int, char *, int);
  26. extern int aspicreat(char *, int);
  27. extern int aspiclose( int );
  28. extern long aspilseek(int, long, int);
  29. #define rmtopen         aspiopen
  30. #define rmtread         aspiread
  31. #define rmtwrite        aspiwrite
  32. #define rmtcreat        aspicreat
  33. #define rmtclose        aspiclose
  34. #define rmtlseek        aspilseek
  35. #else
  36. #define rmtopen        open
  37. #define rmtread        read
  38. #define rmtwrite    write
  39. #define rmtcreat    creat
  40. #define rmtclose    close
  41. #define rmtlseek    lseek
  42. #endif /* ASPI */
  43.  
  44. #define _isrmt(f)       0
  45. #define rmtaccess    access
  46. #define rmtstat        stat
  47. #define rmtlstat    lstat
  48. #define rmtioctl    ioctl
  49. #define rmtdup        dup
  50. #define rmtfstat    fstat
  51. #define rmtfcntl    fcntl
  52. #define rmtisatty    isatty
  53.  
  54. extern long lseek();
  55. #else
  56. #ifndef USG
  57. #define strchr index
  58. #endif
  59.  
  60. #define __REM_BIAS    128
  61. #define RMTIOCTL
  62.  
  63. #ifndef O_CREAT
  64. #define O_CREAT    01000
  65. #endif
  66. extern char *__rmt_path;
  67. extern char *strchr();
  68.  
  69. #define _remdev(path)    ((__rmt_path=strchr(path, ':')) && strncmp(__rmt_path, ":/dev/", 6)==0)
  70. #define _isrmt(fd)        ((fd) >= __REM_BIAS)
  71.  
  72. #define rmtopen(path,oflag,mode) (_remdev(path) ? __rmt_open(path, oflag, mode, __REM_BIAS) : open(path, oflag, mode))
  73. #define rmtaccess(path, amode)    (_remdev(path) ? 0 : access(path, amode))
  74. #define rmtstat(path, buf)    (_remdev(path) ? (errno = EOPNOTSUPP), -1 : stat(path, buf))
  75. #define rmtcreat(path, mode)    (_remdev(path) ? __rmt_open (path, 1 | O_CREAT, mode, __REM_BIAS) : creat(path, mode))
  76. #define rmtlstat(path,buf)    (_remdev(path) ? (errno = EOPNOTSUPP), -1 : lstat(path,buf))
  77.  
  78. #define rmtread(fd, buf, n)    (_isrmt(fd) ? __rmt_read(fd - __REM_BIAS, buf, n) : read(fd, buf, n))
  79. #define rmtwrite(fd, buf, n)    (_isrmt(fd) ? __rmt_write(fd - __REM_BIAS, buf, n) : write(fd, buf, n))
  80. #define rmtlseek(fd, off, wh)    (_isrmt(fd) ? __rmt_lseek(fd - __REM_BIAS, off, wh) : lseek(fd, off, wh))
  81. #define rmtclose(fd)        (_isrmt(fd) ? __rmt_close(fd - __REM_BIAS) : close(fd))
  82. #ifdef RMTIOCTL
  83. #define rmtioctl(fd,req,arg)    (_isrmt(fd) ? __rmt_ioctl(fd - __REM_BIAS, req, arg) : ioctl(fd, req, arg))
  84. #else
  85. #define rmtioctl(fd,req,arg)    (_isrmt(fd) ? (errno = EOPNOTSUPP), -1 : ioctl(fd, req, arg))
  86. #endif
  87. #define rmtdup(fd)        (_isrmt(fd) ? (errno = EOPNOTSUPP), -1 : dup(fd))
  88. #define rmtfstat(fd, buf)    (_isrmt(fd) ? (errno = EOPNOTSUPP), -1 : fstat(fd, buf))
  89. #define rmtfcntl(fd,cmd,arg)    (_isrmt(fd) ? (errno = EOPNOTSUPP), -1 : fcntl (fd, cmd, arg))
  90. #define rmtisatty(fd)        (_isrmt(fd) ? 0 : isatty(fd))
  91.  
  92. #undef RMTIOCTL
  93. extern long lseek(),__rmt_lseek();
  94. #endif
  95.